<?php
$T->loadTpl("./html/".$template."/".$qname.".html");
$T->SetTpl('cssjs','html/cssjs.inc'); 
$T->SetTpl('jsmodel','html/jsmodel.inc');     
  
$today = date('Y-m-d');
$rest = $T->db->query("select am_on,am_off,pm_on,pm_off from sys_rest where role=".$_SESSION['role'])->fetch(PDO::FETCH_ASSOC);
$p=isset($_GET["p"])?$_GET["p"]:"1";
$start_date=isset($_GET["start_date"])?$_GET["start_date"]:"";
$end_date=isset($_GET["end_date"])?$_GET["end_date"]:"";
$where = " and  uid ='".$_SESSION['uid']."'";
if($start_date){$where.=" and date>='".$start_date."'";$T->Set('start_date',$start_date);}
if($end_date){$where.=" and date<='".$end_date."'";$T->Set('end_date',$end_date);}
$offset = ($p-1)*15;
$uid=$_SESSION['uid'];
$list =$T->db->query("select * from sys_attend where 1=1 ".$where." order by date desc limit {$offset},15")->fetchAll(PDO::FETCH_ASSOC);
$str_html = ''; 
foreach ($list as $k => $val) {
    $attend_am_on = empty($val["attend_am_on"])?"":date('Y-m-d H:i:s',$val["attend_am_on"]);
    $attend_am_off = empty($val["attend_am_off"])?"":date('Y-m-d H:i:s',$val["attend_am_off"]);
    $attend_pm_on = empty($val["attend_pm_on"])?"":date('Y-m-d H:i:s',$val["attend_pm_on"]);
    $attend_pm_off = empty($val["attend_pm_off"])?"":date('Y-m-d H:i:s',$val["attend_pm_off"]);
    $late_am = isset($val['late_am'])?$val['late_am']."分钟":"";
    $early_am = isset($val['early_am'])?$val['early_am']."分钟":"";
    $late_pm = isset($val['late_pm'])?$val['late_pm']."分钟":"";
    $early_pm = isset($val['early_pm'])?$val['early_pm']."分钟":"";
    $str_html.='<tr>
                    <td>'.$val["date"].'</td>
                    <td>'.$attend_am_on.'</td>
                    <td>'.$late_am.'</td>
                    <td>'.$attend_am_off.'</td>
                    <td>'.$early_am.'</td>
                    <td>'.$attend_pm_on.'</td>
                    <td>'.$late_pm.'</td>
                    <td>'.$attend_pm_off.'</td>
                    <td>'.$early_pm.'</td>
                    <td>    
                        <button class="layui-btn layui-btn-mini layui-btn-normal ajax"  data-opt="view"  data-id="'.$val["id"].'">
                            <i class="iconfont">&#xe605;</i>查看
                        </button>
                    </td>
                </tr>';
}
$rc=$T->db->query("select count(*) from sys_attend where 1=1".$where)->fetchColumn(0);
if($p<1)$p=1;
$page=getPageHtml_bt($rc,15,$p,"&t=attend_sys");
$page=mb_convert_encoding($page, 'utf-8', 'utf-8');
$T->Set("page",$page);
$T->Set("str_html",$str_html);
$T->Set("am_on",$rest['am_on']);
$T->Set("am_off",$rest['am_off']);
$T->Set("pm_on",$rest['pm_on']);
$T->Set("pm_off",$rest['pm_off']);

$T->Set("template",$template);         
$T->clearNaN();       
$T->clearNoN();
$T->display(); 


